From: Keir Fraser Date: Mon, 19 Oct 2009 15:50:14 +0000 (+0100) Subject: vtd: Disable VT-d if no DRHD units are probed. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~13199 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=6f8b0338a4df30f87865a42bdaec62b445fa762a;p=xen.git vtd: Disable VT-d if no DRHD units are probed. Signed-off-by: Keir Fraser --- diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index b1ce67f741..cfa74f9579 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -266,9 +266,11 @@ int iommu_setup(void) { int rc = -ENODEV; - rc = iommu_hardware_setup(); - - iommu_enabled = (rc == 0); + if ( iommu_enabled ) + { + rc = iommu_hardware_setup(); + iommu_enabled = (rc == 0); + } if ( force_iommu && !iommu_enabled ) panic("IOMMU setup failed, crash Xen for security purpose!\n"); diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index ddf1543fbc..4d5702e729 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1707,7 +1707,7 @@ int intel_vtd_setup(void) struct acpi_drhd_unit *drhd; struct iommu *iommu; - if ( !iommu_enabled ) + if ( list_empty(&acpi_drhd_units) ) return -ENODEV; platform_quirks(); @@ -1760,18 +1760,15 @@ int intel_vtd_setup(void) P(iommu_intremap, "Interrupt Remapping"); #undef P + /* Allocate domain id bitmap, and set bit 0 as reserved. */ drhd = list_entry(acpi_drhd_units.next, typeof(*drhd), list); - if ( drhd != NULL ) - { - /* Allocate domain id bitmap, and set bit 0 as reserved. */ - domid_bitmap_size = cap_ndoms(drhd->iommu->cap); - domid_bitmap = xmalloc_array(unsigned long, - BITS_TO_LONGS(domid_bitmap_size)); - if ( domid_bitmap == NULL ) - goto error; - memset(domid_bitmap, 0, domid_bitmap_size / 8); - __set_bit(0, domid_bitmap); - } + domid_bitmap_size = cap_ndoms(drhd->iommu->cap); + domid_bitmap = xmalloc_array(unsigned long, + BITS_TO_LONGS(domid_bitmap_size)); + if ( domid_bitmap == NULL ) + goto error; + memset(domid_bitmap, 0, domid_bitmap_size / 8); + __set_bit(0, domid_bitmap); scan_pci_devices();